<p>This rule raises an issue when a function parameter is reassigned using the logical OR operator (<code>||</code>) with a literal value as the
fallback.</p>
<h2>Why is this an issue?</h2>
<p>Reassigning function parameters using the logical OR operator (<code>||</code>) creates different behavior than using default parameters, which can
lead to unexpected results.</p>
<p>When you write <code>foo = foo || 'default'</code>, the fallback value is used whenever <code>foo</code> is any falsy value (including
<code>null</code>, <code>0</code>, <code>false</code>, empty string <code>''</code>, etc.). This means legitimate values like <code>0</code> or
<code>false</code> get replaced with the fallback.</p>
<p>Default parameters, on the other hand, only apply when the parameter is specifically <code>undefined</code>. This is usually the intended behavior
when providing fallback values.</p>
<p>Default parameters also make the function signature clearer by showing the expected defaults upfront.</p>
<h3>What is the potential impact?</h3>
<p>This pattern can cause bugs when legitimate falsy values (like <code>0</code>, <code>false</code>, or empty strings) are passed as arguments but
get replaced with the fallback value. This is especially problematic in functions that handle numeric values, boolean flags, or optional strings where
these falsy values have meaning.</p>
<h3>How to fix?</h3>
<p>Replace parameter reassignment with default parameter syntax. This ensures the default value is only used when the parameter is
<code>undefined</code>, not when it’s other falsy values.</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
function setWidth(width) {
  width = width || 100;  // Problem: width=0 becomes 100
  // ...
}

setWidth(0);  // Unexpectedly uses 100 instead of 0
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
function setWidth(width = 100) {
  // width=0 stays 0, only undefined becomes 100
}

setWidth(0);     // Correctly uses 0
setWidth();      // Uses default 100
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-default-parameters.md">prefer-default-parameters</a> </li>
  <li> MDN - Default Parameters - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters">Comprehensive guide to JavaScript default
  parameters and their behavior</a> </li>
  <li> MDN - Logical OR Assignment - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR">Documentation on
  the logical OR operator and its behavior with falsy values</a> </li>
</ul>
